<div class="default-background">
    <h2>{{'USER_DASHBOARD'|translate}}</h2>
    <app-search (search)="doSearch($event)" [searchConfigs]="searchConfigs">
    </app-search>
    <div>
        <div class="table-container">

            <table mat-table [dataSource]="tableSource.dataSource">
                <ng-container matColumnDef="id" sticky>
                    <th mat-header-cell *matHeaderCellDef> {{columnList['id']|translate}} </th>
                    <td mat-cell *matCellDef="let row">
                        <app-copy-field [inputValue]="row.id"></app-copy-field>
                    </td>
                </ng-container>

                <ng-container matColumnDef="email">
                    <th mat-header-cell *matHeaderCellDef> {{columnList['email']|translate}} </th>
                    <td mat-cell *matCellDef="let row"> <app-copy-field [inputValue]="row.email"></app-copy-field> </td>
                </ng-container>

                <ng-container matColumnDef="createdAt">
                    <th mat-header-cell *matHeaderCellDef> {{columnList['createdAt']|translate}} </th>
                    <td mat-cell *matCellDef="let row"> {{row.createdAt | date:'shortDate'}} </td>
                </ng-container>

                <ng-container matColumnDef="locked">
                    <th mat-header-cell *matHeaderCellDef> {{columnList['locked']|translate}} </th>
                    <td mat-cell *matCellDef="let row">
                        <app-editable-boolean [inputValue]="row.locked"
                            (newValue)="doPatchBoolean(row.id,$event,'locked')" [readOnly]="true">
                        </app-editable-boolean>
                    </td>
                </ng-container>

                <ng-container matColumnDef="edit">
                    <th mat-header-cell *matHeaderCellDef class="table-icon">{{columnList['edit']|translate}}</th>
                    <td mat-cell *matCellDef="let row" class="table-icon">
                        <mat-icon (click)="viewUser(row.id)" [color]="'primary'">edit</mat-icon>
                    </td>
                </ng-container>

                <ng-container matColumnDef="token">
                    <th mat-header-cell *matHeaderCellDef class="table-icon">{{columnList['token']|translate}}</th>
                    <td mat-cell *matCellDef="let row" class="table-icon" style="text-align: center;">
                        <mat-icon (click)="revokeUserToken(row.id)" [color]="'accent'">remove_circle</mat-icon>
                    </td>
                </ng-container>
                <tr mat-header-row *matHeaderRowDef="tableSource.displayedColumns(); sticky: true"></tr>
                <tr mat-row *matRowDef="let row; columns: tableSource.displayedColumns();"></tr>
            </table>
        </div>

        <mat-paginator [showFirstLastButtons]="true" [length]="tableSource.totoalItemCount"
            [pageIndex]="tableSource.pageNum" [pageSize]="tableSource.pageSize"
            (page)="tableSource.loadPage($event.pageIndex)">
        </mat-paginator>
    </div>
</div>